#include<stdio.h>
int main()
{
	int L,M;
	int i,t,count;
	int begin,end;
	int tree[10010]={0};
	
	scanf("%d%d",&L,&M);
	while(M--)
	{
		scanf("%d%d",&begin,&end);
		for(i=begin;i<=end;i++)
		{
			tree[i]=1;
		}
	}
	count=0;
	for(i=0;i<=L;i++)
	{
		if(tree[i]==0)
		{
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}
